/*
 * cpu.c
 *
 *  Created on: Apr 18, 2021
 *      Author: gewenbin
 */

/*
 *  Start up a secondary CPU core.
 */
#define __SYLIXOS_KERNEL
#include "config.h"
#include "SylixOS.h"
#include <linux/compat.h>

#define SECONDARY_STARTUP_ADDR  0x1F007F00

VOID  cpuEnable (UINT8 ucCoreNum)
{
    u32 secondary_boot_addr = SECONDARY_STARTUP_ADDR + ucCoreNum * 4;

    writel_relaxed(BSP_CFG_RAM_BASE, secondary_boot_addr);

    /* Ensure the write is visible to the secondary core */
    KN_SMP_MB();

    /* Wakeup secondary cores */
    __asm__ __volatile__(ARM_SEV);
}

/*
 *  Places a secondary CPU core in reset.
 */
VOID cpuDisable (UINT8 ucCoreNum)
{
    /*
     *  TODO:
     */
}
